/*
 * @Author: ljk
 * @Date: 2023-05-23 16:13:01
 * @LastEditors: ljk
 * @LastEditTime: 2023-05-23 16:31:25
 * @Description: 线程模拟
 */
#include <unistd.h>
#include <iostream>
#include <pthread.h>

using namespace std;

void *thread1_run(void *args)
{
    while (1)
    {
        cout << "thread1 running" << endl;
        sleep(1);
    }
}
void *thread2_run(void *args)
{
    while (1)
    {
        cout << "thread2 running" << endl;
        sleep(1);
    }
}
void *thread3_run(void *args)
{
    while (1)
    {
        cout << "thread3 running" << endl;
        sleep(1);
    }
}
int main()
{
    pthread_t t1, t2, t3;
    pthread_create(&t1, NULL, thread1_run, NULL);
    pthread_create(&t2, NULL, thread2_run, NULL);
    pthread_create(&t3, NULL, thread3_run, NULL);

    while (1)
    {
        cout << "master thread running" << endl;
        sleep(1);
    }

    return 0;
}